﻿#pragma once

#include "E_Welfare.nanopb.h"
#include "NFServerComm/NFServerCommon/NFIDescStoreEx.h"
#include "NFServerComm/NFServerCommon/NFIDescTemplate.h"
#include "NFComm/NFShmStl/NFShmVector.h"
#include "NFLogicCommon/NFDescStoreTypeDefines.h"

class WelfareDescEx : public NF_OBJECT_GLOBAL_TEMPLATE_MACRO(WelfareDescEx, EOT_CONST_WELFARE_DESC_EX_ID, NFIDescStoreEx)
public:
	WelfareDescEx();
	virtual ~WelfareDescEx();
	int CreateInit();
	int ResumeInit();
public:
	virtual int Load() override;
	virtual int CheckWhenAllDataLoaded() override;
public:
	uint32_t GetLastChangeUnixSec() const { return m_dwLastChangeUnixSec; }
private:
	int CheckWelfareWithType(const E_Welfare* pDesc);
	int CheckWelfareWithTypeSignIn(const E_Welfare* pDesc);
private:
	int CheckWelfareNodeDesc(const E_Welfare* pDesc);
	int CheckWelfareNodeWithType(const E_Welfare* pDesc, const E_WelfareNode* pNodeDesc);
private:
	int CheckWelfareWorldID(const E_Welfare* pDesc);
	int GetContainWorldOne(const ServerOpenUnixTimeRange& rstTimeRange, std::set<int> &setIncludeWorldID, std::set<int>& setExceptWorldID, bool &bContainAll, bool &bIsExcept);
	int StrContainID(const std::string& strIDRangeList, bool &bIsAll, std::set<int> &setIDs);
	int MergeWorldID(std::set<int>& setA, std::set<int>& setB);
private:
	int CheckLevelRange(const IntRange& stIntRange);
	int CheckShowLevelRange(const IntRange& stOpenLevelIntRange, const IntRange& stShowLevelIntRange);
	int CheckWelfareNodeClickCond(const WelfareNodeClickCond& stWelfareNodeClickCond);
	int CheckWelfareNodeAward(const WelfareNodeAward& stWelfareNodeAward);
private:
	int CheckTimeRange(const UnixTimeRange& stUnixTimeRange);
	int CheckIntRange(const IntRange& stIntRange);
private:
	uint32_t m_dwLastChangeUnixSec;
};
